import type { InjectionKey } from 'vue'
export  interface FormProps  {
    model:Record<string , any>;
    rules?:Record<string , any>;
}

export  interface FormItemProps {
    label:string,
    prop?:string
}
export interface FormContext extends FormProps {
    addField?:(field:FormItemContext)=>void
    removeField?:(field:FormItemContext)=>void
}
export interface FormItemContext {
    validate:(tirgger:string)=>Promise<any>
    prop?:string
    resetField?:()=>void
    clearValidate?:()=>void
}
export interface FormInstance {
    // 验证整个表单
    validate:()=>Promise<any>
    //重置表单
    resetFields:(prop?:string[])=>void
    //清除校验规则
    clearValidate:(prop?:string[])=>void
}
export interface FormItemStatus {
    status:'success'|'error'|'init',
    errorMsg:string,
    isLoding:boolean
}
export interface FormItemInstance {
    validate:(tirgger:string)=>Promise<any>
    resetField?:()=>void
    clearValidate?:()=>void,
    status:FormItemStatus
}
export const FormContextKey:InjectionKey<FormContext> = Symbol('FormContext')
export const FormItemContextKey:InjectionKey<FormItemContext> = Symbol('FormItemContextKey')
